package org.example.demo3.server.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;
import org.example.demo3.pojo.dto.RoomPageQueryDTO;
import org.example.demo3.pojo.entity.Room;
import org.example.demo3.pojo.vo.RoomVO;

@Mapper
public interface RoomMapper {

    /**
     * 插入新房间
     * @param room
     */
    void insertRoom(Room room);

    Page<RoomVO> queryRoom(RoomPageQueryDTO roomPageQueryDTO);

    @Select("select * from test1.room where room_id=#{roomId}")
    Room queryById(String roomId);

    @Update("update test1.room set status=#{status} where room_id=#{roomId}")
    void updateStatusById(@Param("status") Integer status, @Param("roomId") String roomId);

    @Select("select count(*) from test1.room where host_name=#{hostName}")
    Integer queryRoomCountByHostName(String hostName);

    @Select("select count(*) from test1.room where host_name=#{hostName} and status=1")
    Integer queryRoomStatusByHostname(String hostName);

    @Select("select room_id,name,text,host_name,status from test1.room where room_id=#{roomId}")
    RoomVO queryRoomById(String roomId);

    @Delete("delete from test1.room where room_id=#{roomId}")
    void roomDelete(String roomId);
}
